//
//  MoreDetailViewController.m
//  ShrimpCrowdordering
//
//  Created by 郑洲 on 2018/7/25.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "MoreDetailViewController.h"

#import "AllCommentViewController.h"

#import "PayViewController.h"
#import "CommitOrderViewController.h"

#import "CommentTableViewCell.h"
#import "MoreDesignView.h"
#import "ShareView.h"

#import "CommentTableViewCell.h"
#import "RankListCell.h"
#import "KDCycleBannerView.h"

#import <AlipaySDK/AlipaySDK.h>
#import <TencentOpenAPI/QQApiInterface.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import "WeiboSDK.h"
#import "WXApi.h"
#import "UIImage+GradientColor.h"
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>

#define ARC4RANDOM_MAX      0x100000000

@interface MoreDetailViewController ()<UITableViewDelegate, UITableViewDataSource, KDCycleBannerViewDataSource, KDCycleBannerViewDelegate, UITextViewDelegate ,TencentSessionDelegate, UITextFieldDelegate>{
    CGFloat money;
}

@property (nonatomic, strong) BaseTableView *tableView;
@property (nonatomic, strong) KDCycleBannerView * cycleBannerViewBottom;//轮播图

@property (nonatomic, strong) UIButton *collectionBtn;
@property (nonatomic, strong) UIButton *commentBtn;
@property (nonatomic, strong) UIButton *shareBtn;

@property (nonatomic, strong) NSMutableArray *similarArray;
@property (nonatomic, strong) NSMutableArray *commentArr;

@property (nonatomic, strong) ProductModel *pro;
@property (nonatomic, strong) NSArray *ideaArray;

@property (nonatomic, strong) UIView *commentView;
@property (nonatomic, copy) NSString *appraiseId;
@property (nonatomic, strong) UIButton *buyView;

@property (nonatomic, strong) UIButton *shadowBtn;
@property (nonatomic, strong) ShareView *shareView;
@property (nonatomic, copy) NSString *shareId;
@property (nonatomic, copy) NSString *shareName;
@property (nonatomic, copy) NSString *shareLink;

@property (nonatomic, strong) TencentOAuth *tencentOAuth;

@property (nonatomic, strong) UIView *rewardView;
@property (nonatomic, strong) UILabel *rewardMoney;
@property (nonatomic, copy)   NSString * rewardType;

@property (nonatomic, strong) AVPlayer *player;
@property (nonatomic, strong) AVPlayerViewController  *playerView;
@property (nonatomic, strong) UIButton *videoBtn;

@end

@implementation MoreDetailViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    [kNotificationCenter addObserver:self selector:@selector(shareSuccess) name:@"WechatShare" object:nil];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:nil];
    [self.shadowBtn removeFromSuperview];
    [self.shareView removeFromSuperview];
    [kNotificationCenter removeObserver:self name:@"WechatShare" object:nil];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGFloat yoffset = scrollView.contentOffset.y;
    
    if (yoffset >0) {
        
        CGFloat alpha = MIN(1, yoffset/(ScreenX375(355) + STATUS_BAR_HEIGHT)); //150：上拉150距离背景图片alpha=1
        if (alpha > 0.99) {
            [self.navigationController.navigationBar setShadowImage:[HttpManager createImageWithColor:REXADECIMALCOLOR(@"#f4f4f4")]];
        }else {
            [self.navigationController.navigationBar setShadowImage:[UIImage new]];
        }
        
        UIImage *image = [HttpManager createImageWithColor:RGBACOLOR(255, 255, 255, alpha)];
        
        [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.commentArr = [NSMutableArray array];
    self.similarArray = [NSMutableArray array];
    self.ideaArray = [NSArray array];
    self.appraiseId = @"";
    self.rewardType = @"1";
    if (!_proId) {
        _proId = @"";
    }
    
    UIButton *shareBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(44), STATUS_BAR_HEIGHT, ScreenX375(44), ScreenX375(44))];
    [shareBtn setImage:ImageWithName(@"分享") forState:UIControlStateNormal];
    shareBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 5, 0, -5);
    [shareBtn addTarget:self action:@selector(getShare) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareBtn];
    
    self.tableView = [[BaseTableView alloc] initWithFrame:CGRectMake(0, -NAVIGATION_BAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - ScreenX375(49)) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    [self getComment];
    [self getSimilar];
    [self getData];
}

- (void)setBottomBar {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - ScreenX375(49) -NAVIGATION_BAR_HEIGHT, SCREEN_WIDTH, ScreenX375(49))];
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    
    NSArray *imageArr = @[@"点赞",@"评论 copy 2",@"转发",@"心愿订单"];
    NSArray *detailArr = @[_pro.zanNum,_pro.appraiseNum,_pro.shareNum,@"心愿订单"];
    for (int i = 0; i < imageArr.count; i++) {
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(49) * i, 0, ScreenX375(49), ScreenX375(49))];
        [button setImage:ImageWithName(imageArr[i]) forState:UIControlStateNormal];
        [button setTitleColor:FONTCOLOR_GRAY forState:UIControlStateNormal];
        [button setTitle:detailArr[i] forState:UIControlStateNormal];
        button.titleLabel.font = Kfont(10);
        [view addSubview:button];
        
        CGSize imgViewSize,titleSize,btnSize;
        UIEdgeInsets imageViewEdge,titleEdge;
        CGFloat heightSpace = 10.0f;
        
        //设置按钮内边距
        imgViewSize = button.imageView.bounds.size;
        titleSize = button.titleLabel.bounds.size;
        btnSize = button.bounds.size;
        imageViewEdge = UIEdgeInsetsMake(10, 0, btnSize.height -imgViewSize.height - heightSpace, - titleSize.width);
        titleEdge = UIEdgeInsetsMake(20, - imgViewSize.width, 0.0, 0.0);
        [button setImageEdgeInsets:imageViewEdge];
        [button setTitleEdgeInsets:titleEdge];
        
        if (i == 0) {
            self.collectionBtn = button;
            [self.collectionBtn addTarget:self action:@selector(praiseClick:) forControlEvents:UIControlEventTouchUpInside];
            if ([_pro.isZan integerValue]) {
                [self.collectionBtn setImage:ImageWithName(@"已点赞") forState:UIControlStateNormal];
            }
        }else if (i == 1) {
            self.commentBtn = button;
            [self.commentBtn addTarget:self action:@selector(commentClick) forControlEvents:UIControlEventTouchUpInside];
        }else if (i == 2) {
            self.shareBtn = button;
            [self.shareBtn addTarget:self action:@selector(getShare) forControlEvents:UIControlEventTouchUpInside];
        }else if (i == 3) {
            if ([_pro.isWish integerValue]) {
                [button setImage:ImageWithName(@"心愿单") forState:UIControlStateNormal];
            }
            imageViewEdge = UIEdgeInsetsMake(10, 10, btnSize.height -imgViewSize.height - heightSpace, - titleSize.width);
            [button setImageEdgeInsets:imageViewEdge];
            [button addTarget:self action:@selector(wishClick:) forControlEvents:UIControlEventTouchUpInside];
        }
    }
    
    if ([_pro.status integerValue]) {
        UIImage *bgImg = [UIImage gradientColorImageFromColors:@[REXADECIMALCOLOR(@"#ff1061"),REXADECIMALCOLOR(@"#fd4c4e")] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(SCREEN_WIDTH - ScreenX375(196), ScreenX375(49))];
        UIImageView *buyBgView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(196), 0, SCREEN_WIDTH - ScreenX375(196), ScreenX375(49))];
        buyBgView.image = bgImg;
        [view addSubview:buyBgView];
        
        UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(7), SCREEN_WIDTH - ScreenX375(196), ScreenX375(17))];
        valueLabel.text = [NSString stringWithFormat:@"¥%@",_pro.garmentPrice];
        valueLabel.textColor = REXADECIMALCOLOR(@"#ffffff");
        valueLabel.font = KBlodfont(15);
        valueLabel.textAlignment = NSTextAlignmentCenter;
        [buyBgView addSubview:valueLabel];
        
        UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(26), SCREEN_WIDTH - ScreenX375(196), ScreenX375(16))];
        noteLabel.text = @"成衣购买";
        noteLabel.textColor = REXADECIMALCOLOR(@"#ffffff");
        noteLabel.font = Kfont(14);
        noteLabel.textAlignment = NSTextAlignmentCenter;
        [buyBgView addSubview:noteLabel];
        
        UIButton *buyBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(196), 0, SCREEN_WIDTH - ScreenX375(196), ScreenX375(49))];
        buyBtn.tag = 1111;
        [buyBtn addTarget:self action:@selector(buyClick:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:buyBtn];
    }else {
        NSArray *detailArr = @[_pro.copyrightAmount,_pro.authorizedAmount];
        NSArray *noteArr = @[@"版权购买",@"授权购买"];
        for (int i = 0; i < 2; i++) {
            UIImage *bgImg = [UIImage gradientColorImageFromColors:@[REXADECIMALCOLOR(@"#ff1061"),REXADECIMALCOLOR(@"#fd4c4e")] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(SCREEN_WIDTH - ScreenX375(196), ScreenX375(49))];
            if (i == 0) {
                bgImg = [UIImage gradientColorImageFromColors:@[REXADECIMALCOLOR(@"#fed1dc"),REXADECIMALCOLOR(@"#fed1dc")] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(SCREEN_WIDTH - ScreenX375(196), ScreenX375(49))];
            }
            UIImageView *buyBgView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(196) + i * (SCREEN_WIDTH - ScreenX375(196)) / 2, 0, (SCREEN_WIDTH - ScreenX375(196)) / 2, ScreenX375(49))];
            buyBgView.image = bgImg;
            [view addSubview:buyBgView];
            
            UILabel *valueLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(7), (SCREEN_WIDTH - ScreenX375(196)) / 2, ScreenX375(17))];
            valueLabel.text = [NSString stringWithFormat:@"¥%@",detailArr[i]];
            valueLabel.textColor = REXADECIMALCOLOR(@"#ffffff");
            if (i == 0) {
                valueLabel.textColor = REXADECIMALCOLOR(@"#ff235d");
            }
            valueLabel.font = KBlodfont(15);
            valueLabel.textAlignment = NSTextAlignmentCenter;
            [buyBgView addSubview:valueLabel];
            
            UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(26), (SCREEN_WIDTH - ScreenX375(196)) / 2, ScreenX375(16))];
            noteLabel.text = noteArr[i];
            noteLabel.textColor = REXADECIMALCOLOR(@"#ffffff");
            if (i == 0) {
                noteLabel.textColor = REXADECIMALCOLOR(@"#ff235d");
            }
            noteLabel.font = Kfont(14);
            noteLabel.textAlignment = NSTextAlignmentCenter;
            [buyBgView addSubview:noteLabel];
            
            UIButton *buyBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(196) + i * (SCREEN_WIDTH - ScreenX375(196)) / 2, 0, (SCREEN_WIDTH - ScreenX375(196)) / 2, ScreenX375(49))];
            buyBtn.tag = 1000 + i;
            [buyBtn addTarget:self action:@selector(buyClick:) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:buyBtn];
        }
    }
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.5)];
    line.backgroundColor = REXADECIMALCOLOR(@"#f4f4f4");
    [view addSubview:line];
}

- (void)share {
    if (!self.shareView) {
        self.shadowBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        self.shadowBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        [self.shadowBtn addTarget:self action:@selector(hidden) forControlEvents:UIControlEventTouchUpInside];
        self.shadowBtn.hidden = YES;
        [kKeyWindow addSubview:self.shadowBtn];
        
        self.shareView = [[ShareView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT , SCREEN_WIDTH, ScreenX375(180))];
        __weak __typeof(self) weakSelf = self;
        self.shareView.cancel = ^{
            [weakSelf hidden];
        };
        self.shareView.wxClick = ^{
            SendMessageToWXReq *sendReq = [[SendMessageToWXReq alloc] init];
            sendReq.bText = NO;
            sendReq.scene = 0;
            
            // 2.创建分享内容
            WXMediaMessage *message = [WXMediaMessage message];
            //分享标题
            message.title = @"虾拼";
            // 描述
            message.description = weakSelf.shareName;
            //分享图片,使用SDK的setThumbImage方法可压缩图片大小
            //                message.thumbData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMAGEHEADER,self.model.pics.firstObject]]];
            [message setThumbImage:[UIImage imageNamed:@"虾拼 logo"]];
            
            //创建多媒体对象
            WXWebpageObject *webObj = [WXWebpageObject object];
            // 点击后的跳转链接
            webObj.webpageUrl = weakSelf.shareLink;
            message.mediaObject = webObj;
            sendReq.message = message;
            [WXApi sendReq:sendReq];
            [weakSelf hidden];
        };
        self.shareView.wxGroupClick = ^{
            SendMessageToWXReq *sendReq = [[SendMessageToWXReq alloc] init];
            sendReq.bText = NO;
            sendReq.scene = 1;
            
            // 2.创建分享内容
            WXMediaMessage *message = [WXMediaMessage message];
            //分享标题
            message.title = @"虾拼";
            // 描述
            message.description = weakSelf.shareName;
            //分享图片,使用SDK的setThumbImage方法可压缩图片大小
            [message setThumbImage:[UIImage imageNamed:@"虾拼 logo"]];
            
            //创建多媒体对象
            WXWebpageObject *webObj = [WXWebpageObject object];
            // 点击后的跳转链接
            webObj.webpageUrl = weakSelf.shareLink;
            message.mediaObject = webObj;
            sendReq.message = message;
            [WXApi sendReq:sendReq];
            [weakSelf hidden];
        };
        self.shareView.qqClick = ^{
            weakSelf.tencentOAuth = [[TencentOAuth alloc] initWithAppId:kQQAppKey andDelegate:weakSelf];
            
            NSString *url = weakSelf.shareLink;
            NSString *imageUrl = [NSString stringWithFormat:@"%@",IMAGEHEADER];
            
            QQApiNewsObject *share = [QQApiNewsObject objectWithURL:[NSURL URLWithString:url] title:@"虾拼" description:weakSelf.shareName previewImageURL:[NSURL URLWithString:imageUrl]];
            SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:share];
            
            //分享到qq
            [QQApiInterface sendReq:req];
            [weakSelf hidden];
        };
        self.shareView.qqGroupClick = ^{
            weakSelf.tencentOAuth = [[TencentOAuth alloc] initWithAppId:kQQAppKey andDelegate:weakSelf];
            
            NSString *url = weakSelf.shareLink;
            NSString *imageUrl = [NSString stringWithFormat:@"%@",IMAGEHEADER];
            
            QQApiNewsObject *share = [QQApiNewsObject objectWithURL:[NSURL URLWithString:url] title:@"虾拼" description:weakSelf.shareName previewImageURL:[NSURL URLWithString:imageUrl]];
            SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:share];
            
            //分享到qq
            [QQApiInterface SendReqToQZone:req];
            [weakSelf hidden];
        };
        self.shareView.wbClick = ^{
            //微博
            WBMessageObject *message = [WBMessageObject message];
            message.text = [NSString stringWithFormat:@"虾拼 %@  %@",weakSelf.shareName,weakSelf.shareLink];
            
            WBAuthorizeRequest *authRequest = [WBAuthorizeRequest request];
            authRequest.redirectURI = kWeiboAppRedirectURL;
            authRequest.scope = @"all";
            
            WBSendMessageToWeiboRequest *sharerequest = [WBSendMessageToWeiboRequest requestWithMessage:message authInfo:authRequest access_token:nil];
            [WeiboSDK sendRequest:sharerequest];
            [weakSelf hidden];
        };
        [kKeyWindow addSubview:self.shareView];
    }
    self.shadowBtn.hidden = NO;
    [UIView animateWithDuration:0.3 animations:^{
        self.shareView.frame = CGRectMake(0, SCREEN_HEIGHT - ScreenX375(180), SCREEN_WIDTH, ScreenX375(180));
    }];
}

- (void)hidden {
    [UIView animateWithDuration:0.3 animations:^{
        self.shareView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, ScreenX375(180));
    } completion:^(BOOL finished) {
        self.shadowBtn.hidden = YES;
    }];
}

- (void)concern:(UIButton *)concernBtn {
    if ([_pro.isFollow integerValue]) {
        _pro.isFollow = @"0";
        [HttpManager showNoteMsg:@"取消关注成功"];
    }else {
        _pro.isFollow = @"1";
        [HttpManager showNoteMsg:@"关注成功"];
    }
    [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/concern",REQUESTHEADER] andParameter:@{@"concernId":kNSUDefaultReadKey(@"userId"),@"concernedId":_pro.Id} success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            if ([self.pro.isFollow integerValue]) {
                [concernBtn setTitle:@"已关注" forState:UIControlStateNormal];
                [concernBtn setTitleColor:FONTCOLOR_GRAY forState:UIControlStateNormal];
                [concernBtn setImage:nil forState:UIControlStateNormal];
                concernBtn.backgroundColor = REXADECIMALCOLOR(@"#f0f0f0");
            }else {
                [concernBtn setTitle:@" 关注" forState:UIControlStateNormal];
                [concernBtn setTitleColor:FONTCOLOR_BLACK forState:UIControlStateNormal];
                [concernBtn setImage:ImageWithName(@"+") forState:UIControlStateNormal];
                concernBtn.backgroundColor = REXADECIMALCOLOR(@"#ffd100");
            }
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)showAll:(UIButton *)button {
    AllCommentViewController *vc = [[AllCommentViewController alloc] init];
    vc.proId = _proId;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)close {
    [_commentView removeFromSuperview];
}

- (void)praiseClick:(UIButton *)button {
    [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/zan",REQUESTHEADER] andParameter:@{@"proId":_proId,@"userId":kNSUDefaultReadKey(@"userId"),@"type":@"0"} success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            if ([self.pro.isZan integerValue]) {
                self.pro.isZan = @"0";
                [self.collectionBtn setImage:ImageWithName(@"点赞") forState:UIControlStateNormal];
                self.pro.zanNum = [NSString stringWithFormat:@"%ld",[self.pro.zanNum integerValue] - 1];
            }else {
                self.pro.isZan = @"1";
                [self.collectionBtn setImage:ImageWithName(@"已点赞") forState:UIControlStateNormal];
                self.pro.zanNum = [NSString stringWithFormat:@"%ld",[self.pro.zanNum integerValue] + 1];
            }
            [self.collectionBtn setTitle:self.pro.zanNum forState:UIControlStateNormal];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)wishClick:(UIButton *)button {
    [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/wish",REQUESTHEADER] andParameter:@{@"proId":_proId,@"userId":kNSUDefaultReadKey(@"userId")} success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            if ([self.pro.isWish integerValue]) {
                self.pro.isWish = @"0";
                [button setImage:ImageWithName(@"心愿订单") forState:UIControlStateNormal];
            }else {
                self.pro.isWish = @"1";
                [button setImage:ImageWithName(@"心愿单") forState:UIControlStateNormal];
            }
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)shareSuccess {
    NSDictionary *parameter = @{@"id":_shareId,@"userId":kNSUDefaultReadKey(@"userId")};
    [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/shareSuccess",REQUESTHEADER] andParameter:parameter success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            [HttpManager showNoteMsg:@"分享成功"];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)getShare {
    [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/share",REQUESTHEADER] andParameter:@{@"proId":_proId,@"userId":kNSUDefaultReadKey(@"userId"),@"type":@"3"} success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            self.shareId = [NSString stringWithFormat:@"%@",successResponse[@"data"][@"id"]];
            self.shareLink = [NSString stringWithFormat:@"%@",successResponse[@"data"][@"url"]];
            self.shareName = self.pro.proName;
            [self share];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)commentClick {
    if (!_commentView) {
        _commentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        _commentView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        
        UIView *commentBg = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(24), ScreenX375(210), SCREEN_WIDTH - ScreenX375(48), ScreenX375(194))];
        commentBg.backgroundColor = REXADECIMALCOLOR(@"#f5f5f5");
        commentBg.layer.cornerRadius = ScreenX375(8);
        commentBg.clipsToBounds = YES;
        [_commentView addSubview:commentBg];
        
        UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(29), ScreenX375(29))];
        [closeBtn setImage:ImageWithName(@"关闭") forState:UIControlStateNormal];
        [closeBtn addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
        [commentBg addSubview:closeBtn];
        
        UITextView *commentText = [[UITextView alloc] initWithFrame:CGRectMake(ScreenX375(25), ScreenX375(23), SCREEN_WIDTH - ScreenX375(98), ScreenX375(105))];
        commentText.backgroundColor = [UIColor whiteColor];
        commentText.font = Kfont(14);
        commentText.layer.cornerRadius = ScreenX375(4);
        commentText.clipsToBounds = YES;
        commentText.text = @"写评论...";
        commentText.tag = 555;
        commentText.textColor = REXADECIMALCOLOR(@"#999999");
        commentText.delegate = self;
        [commentBg addSubview:commentText];
        
        UIImage *bgImg = [UIImage gradientColorImageFromColors:@[REXADECIMALCOLOR(@"#ff1162"),REXADECIMALCOLOR(@"#fe4e4e")] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(ScreenX375(103), ScreenX375(112))];
        UIButton *commitBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(112), ScreenX375(144), ScreenX375(103), ScreenX375(30))];
        [commitBtn setTitle:@"提交评论" forState:UIControlStateNormal];
        [commitBtn setTitleColor:REXADECIMALCOLOR(@"#ffffff") forState:UIControlStateNormal];
        commitBtn.titleLabel.font = Kfont(15);
        [commitBtn setBackgroundImage:bgImg forState:UIControlStateNormal];
        commitBtn.layer.cornerRadius = ScreenX375(15);
        commitBtn.layer.masksToBounds = YES;
        [commitBtn addTarget:self action:@selector(commitComment) forControlEvents:UIControlEventTouchUpInside];
        [commentBg addSubview:commitBtn];
    }
    [kKeyWindow addSubview:_commentView];
}

- (void)commitComment {
    UITextView *textView = [_commentView viewWithTag:555];
    if (textView.text.length == 0) {
        [HttpManager showNoteMsg:@"请输入评论内容"];
        return;
    }
    NSDictionary *parameter = @{@"proId":_proId,@"content":textView.text,@"userId":kNSUDefaultReadKey(@"userId")};
    if (_appraiseId.length > 0) {
        parameter=@{@"proId":_proId,@"content":textView.text,@"userId":kNSUDefaultReadKey(@"userId"),@"parentId":self.appraiseId};
    }
    [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/appraisePro",REQUESTHEADER] andParameter:parameter success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            [HttpManager showNoteMsg:@"评论成功"];
            [self close];
            [self getComment];
            self.appraiseId = @"";
            textView.textColor = REXADECIMALCOLOR(@"#999999");
            textView.text = @"写评论...";
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)closeReward {
    UITextField *field = [_rewardView viewWithTag:777];
    field.text = @"";
    [_rewardView removeFromSuperview];
}

- (void)rewardAction {
    if (!_rewardView) {
        _rewardView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        _rewardView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.50];
        
        UIView *rewardBg = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(38), ScreenX375(119), SCREEN_WIDTH - ScreenX375(76), ScreenX375(363))];
        rewardBg.backgroundColor = [UIColor whiteColor];
        rewardBg.layer.cornerRadius = ScreenX375(6);
        rewardBg.clipsToBounds = YES;
        [_rewardView addSubview:rewardBg];
        
        UIButton *closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(109), 0, ScreenX375(33), ScreenX375(33))];
        [closeBtn setImage:ImageWithName(@"关闭") forState:UIControlStateNormal];
        [closeBtn addTarget:self action:@selector(closeReward) forControlEvents:UIControlEventTouchUpInside];
        [rewardBg addSubview:closeBtn];
        
        UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - ScreenX375(136)) / 2, ScreenX375(5), ScreenX375(60), ScreenX375(60))];
        logo.image = ImageWithName(@"默认客服头像");
        [rewardBg addSubview:logo];
        
        UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(72), SCREEN_WIDTH - ScreenX375(76), ScreenX375(18))];
        noteLabel.text = @"你的打赏是我原创最大的动力！";
        noteLabel.font = Kfont(16);
        noteLabel.textAlignment = NSTextAlignmentCenter;
        noteLabel.textColor = REXADECIMALCOLOR(@"#212121");
        [rewardBg addSubview:noteLabel];
        
        _rewardMoney = [[UILabel alloc] initWithFrame:CGRectMake(0, ScreenX375(112), SCREEN_WIDTH - ScreenX375(76), ScreenX375(50))];
        _rewardMoney.font = KBlodfont(48);
        _rewardMoney.textColor = REXADECIMALCOLOR(@"#f5a623");
        _rewardMoney.textAlignment = NSTextAlignmentCenter;
        [rewardBg addSubview:_rewardMoney];
        
        UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(5), ScreenX375(30))];
        
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(ScreenX375(20), ScreenX375(184), SCREEN_WIDTH - ScreenX375(116), ScreenX375(30))];
        textField.placeholder = @"留个言，让他记得你";
        textField.layer.cornerRadius = ScreenX375(4);
        textField.layer.borderColor = REXADECIMALCOLOR(@"#eaeaea").CGColor;
        textField.layer.borderWidth = 0.8;
        textField.clipsToBounds = YES;
        textField.leftView = leftView;
        textField.delegate = self;
        textField.returnKeyType = UIReturnKeyDone;
        textField.leftViewMode = UITextFieldViewModeAlways;
        textField.font = Kfont(13);
        textField.tag = 777;
        [rewardBg addSubview:textField];
        
        NSArray *payArr = @[@"微信支付",@"支付宝支付"];
        for (int i = 0; i < payArr.count ; i++) {
            UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(70) + i * ScreenX375(116), ScreenX375(236), ScreenX375(44), ScreenX375(44))];
            [button setBackgroundImage:ImageWithName(payArr[i]) forState:UIControlStateNormal];
            button.tag = 700 + i;
            [button addTarget:self action:@selector(selectRewardType:) forControlEvents:UIControlEventTouchUpInside];
            [rewardBg addSubview:button];
        }
        
        UIImageView *noteImg = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(102), ScreenX375(268), ScreenX375(16), ScreenX375(16))];
        noteImg.image = ImageWithName(@"选择");
        noteImg.layer.cornerRadius = ScreenX375(8);
        noteImg.clipsToBounds = YES;
        noteImg.tag = 888;
        [rewardBg addSubview:noteImg];
        
        UIImage *bgImg = [UIImage gradientColorImageFromColors:@[REXADECIMALCOLOR(@"#ff1162"),REXADECIMALCOLOR(@"#fe4e4e")] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(ScreenX375(100), ScreenX375(34))];
        UIButton *commitBtn = [[UIButton alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - ScreenX375(176)) / 2, ScreenX375(305), ScreenX375(100), ScreenX375(34))];
        [commitBtn setTitle:@"提交" forState:UIControlStateNormal];
        [commitBtn setTitleColor:REXADECIMALCOLOR(@"#ffffff") forState:UIControlStateNormal];
        commitBtn.titleLabel.font = Kfont(15);
        [commitBtn setBackgroundImage:bgImg forState:UIControlStateNormal];
        commitBtn.layer.cornerRadius = ScreenX375(17);
        commitBtn.layer.masksToBounds = YES;
        [commitBtn addTarget:self action:@selector(rewardPro) forControlEvents:UIControlEventTouchUpInside];
        [rewardBg addSubview:commitBtn];
    }
    money = ((arc4random() % 100) + 1) / 100.0 * [_pro.rewardAmount floatValue];
    money = 0.1;
    NSString *moneyStr = [NSString stringWithFormat:@"%.1f元",money];
    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:moneyStr];
    [attributedStr addAttribute:NSFontAttributeName value:Kfont(16) range:NSMakeRange(moneyStr.length - 1, 1)];
    _rewardMoney.attributedText = attributedStr;
    [kKeyWindow addSubview:_rewardView];
}

- (void)selectRewardType:(UIButton *)button {
    UIImageView *noteImg = [kKeyWindow viewWithTag:888];
    if (button.tag == 700) {
        self.rewardType = @"1";
        noteImg.frame = CGRectMake(ScreenX375(102), ScreenX375(268), ScreenX375(16), ScreenX375(16));
    }else {
        self.rewardType = @"0";
        noteImg.frame = CGRectMake(ScreenX375(218), ScreenX375(268), ScreenX375(16), ScreenX375(16));
    }
}

- (void)rewardPro {
    [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/reward",REQUESTHEADER] andParameter:@{@"userId":kNSUDefaultReadKey(@"userId"),@"proId":_proId,@"price":[NSString stringWithFormat:@"%.1f",money],@"massage":[(UITextField *)[kKeyWindow viewWithTag:777] text]} success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/pay",REQUESTHEADER] andParameter:@{@"ordNum":[NSString stringWithFormat:@"%@",successResponse[@"data"][@"rewardNum"]],@"isBalance":@"0",@"payType":self.rewardType} success:^(id successResponse) {
                NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
                if ([status isEqualToString:@"200"]) {
                    if ([self.rewardType isEqualToString:@"0"]) {
                        NSString *appScheme = @"xiapin";
                        
                        // NOTE: 将签名成功字符串格式化为订单字符串,请严格按照该格式
                        NSString *orderString = successResponse[@"data"][@"data"];
                        
                        // NOTE: 调用支付结果开始支付
                        [[AlipaySDK defaultService] payOrder:orderString fromScheme:appScheme callback:^(NSDictionary *resultDic) {
                            NSLog(@"reslut = %@",resultDic);
                        }];
                    }else {
                        NSDictionary *wechatPayDic = successResponse[@"data"][@"data"];
                        PayReq *req = [[PayReq alloc] init];
                        req.openID = [wechatPayDic objectForKey:@"appid"];
                        req.partnerId = [wechatPayDic objectForKey:@"partnerid"];
                        req.prepayId = [wechatPayDic objectForKey:@"prepayid"];
                        req.package = [wechatPayDic objectForKey:@"package"];
                        req.nonceStr = [wechatPayDic objectForKey:@"noncestr"];
                        req.timeStamp = [[wechatPayDic objectForKey:@"timestamp"] intValue];
                        req.sign = [wechatPayDic objectForKey:@"sign"];
                        [WXApi sendReq:req];
                    }
                }
            } andFailure:^(id failureResponse) {
                [HttpManager showFail];
            }];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)buyClick:(UIButton *)button {
    if (![_pro.canBuy integerValue]) {
        [HttpManager showNoteMsg:@"暂时无法购买"];
        return;
    }
    if (button.tag == 1111) {
        CommitOrderViewController *vc = [[CommitOrderViewController alloc] init];
        vc.picUrl = _pro.garmentPic;
        vc.proName = _pro.proName;
        vc.price = _pro.garmentPrice;
        vc.proId = _proId;
        vc.isCopyRight = @"0";
        vc.type = _pro.type;
        vc.size = _pro.size;
        vc.makeTime = _pro.makeTime;
        [self.navigationController pushViewController:vc animated:YES];
    }else {
        NSArray *arr = @[_pro.copyrightAmount,_pro.authorizedAmount];
        NSArray *array = @[@"1",@"0"];
        PayViewController *vc = [[PayViewController alloc] init];
        vc.picUrl = _pro.coverPics[0];
        vc.proName = _pro.proName;
        vc.price = arr[button.tag - 1000];
        vc.proId = _proId;
        vc.isCopyRight = array[button.tag - 1000];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (void)hiddenBuyView {
    [_buyView removeFromSuperview];
}

- (void)typeSelect:(UIButton *)button {
    if (button.tag == 200) {
        button.selected = YES;
        UIButton *btn = [kKeyWindow viewWithTag:201];
        btn.selected = NO;
    }else if (button.tag == 201) {
        button.selected = YES;
        UIButton *btn = [kKeyWindow viewWithTag:200];
        btn.selected = NO;
    }
}

- (void)getComment {
    [HttpManager postHttpRequestByGet:[NSString stringWithFormat:@"%@api/getProAppraise",REQUESTHEADER] andParameter:@{@"proId":_proId,@"page":@"1",@"pageSiza":@"1"} success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            [self.commentArr removeAllObjects];
            NSError *error;
            for (NSDictionary *dic in successResponse[@"data"][@"appraises"]) {
                CommentModel *model = [[CommentModel alloc] initWithDictionary:dic error:&error];
                [self.commentArr addObject:model];
            }
            [self.tableView reloadData];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)getSimilar {
    [HttpManager postHttpRequestByGet:[NSString stringWithFormat:@"%@api/likePro",REQUESTHEADER] andParameter:@{@"proId":_proId,@"userId":kNSUDefaultReadKey(@"userId")} success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            NSError *error;
            for (NSDictionary *dic in successResponse[@"data"][@"list"]) {
                DesignModel *model = [[DesignModel alloc] initWithDictionary:dic error:&error];
                [self.similarArray addObject:model];
            }
            [self.tableView reloadData];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)getData {
    [HttpManager postHttpRequestByGet:[NSString stringWithFormat:@"%@api/proDetail",REQUESTHEADER] andParameter:@{@"proId":_proId,@"userId":kNSUDefaultReadKey(@"userId")} success:^(id successResponse) {
        NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
        if ([status isEqualToString:@"200"]) {
            NSError *error;
            ProductModel *proModel = [[ProductModel alloc] initWithDictionary:successResponse[@"data"][@"productInfo"] error:&error];
            self.pro = proModel;
            self.pro.isWish = [NSString stringWithFormat:@"%@",successResponse[@"data"][@"isWish"]];
            self.ideaArray = self.pro.proIdeas;
            
            UIButton *rewardBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(58), SCREEN_HEIGHT - ScreenX375(49) -NAVIGATION_BAR_HEIGHT - ScreenX375(139), ScreenX375(52), ScreenX375(62))];
            if ([successResponse[@"data"][@"isReward"] integerValue]) {
                [rewardBtn setImage:ImageWithName(@"已打赏") forState:UIControlStateNormal];
            }else {
                [rewardBtn setImage:ImageWithName(@"打赏") forState:UIControlStateNormal];
            }
            [rewardBtn addTarget:self action:@selector(rewardAction) forControlEvents:UIControlEventTouchUpInside];
            [self.view addSubview:rewardBtn];
            
            [self setBottomBar];
            [self.cycleBannerViewBottom reloadDataWithCompleteBlock:nil];
            [self.tableView reloadData];
        }else {
            [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
        }
    } andFailure:^(id failureResponse) {
        [HttpManager showFail];
    }];
}

- (void)playVideo {
    NSString *playString = _pro.videoUrl;
    //视频播放的url
    NSURL *playerURL = [NSURL URLWithString:playString];
    //初始化
    self.playerView = [[AVPlayerViewController alloc]init];
    //AVPlayerItem 视频的一些信息  创建AVPlayer使用的
    AVPlayerItem *item = [[AVPlayerItem alloc]initWithURL:playerURL];
    //通过AVPlayerItem创建AVPlayer
    self.player = [[AVPlayer alloc]initWithPlayerItem:item];
    //给AVPlayer一个播放的layer层
    AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.player];
    layer.frame = CGRectMake(0, 100, self.view.frame.size.width, 200);
    layer.backgroundColor = [UIColor greenColor].CGColor;
    //设置AVPlayer的填充模式
    layer.videoGravity = AVLayerVideoGravityResize;
    //设置AVPlayerViewController内部的AVPlayer为刚创建的AVPlayer
    self.playerView.player = self.player;
    //关闭AVPlayerViewController内部的约束
    self.playerView.view.translatesAutoresizingMaskIntoConstraints = YES;
    [self presentViewController:self.playerView animated:YES completion:nil];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 5 + _ideaArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 3 + _ideaArray.count) {
        if (self.commentArr.count == 0) {
            return 0;
        }else {
            return 2;
        }
    }else if (section == 2 + _ideaArray.count) {
        if (_pro) {
            if ([_pro.status integerValue]) {
                return 2;
            }
        }
        return 1;
    }
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        if (indexPath.row == 1) {
            static NSString *cellId = @"personInfoCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            for (UIView *view in cell.subviews) {
                [view removeFromSuperview];
            }
            if (_pro) {
                UIImageView *headView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(15), ScreenX375(40), ScreenX375(40))];
                headView.clipsToBounds = YES;
                headView.layer.cornerRadius = ScreenX375(20);
                [headView sd_setImageWithURL:[NSURL URLWithString:_pro.userPic] placeholderImage:nil options:SDWebImageRetryFailed];
                [cell addSubview:headView];
                
                UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(70), ScreenX375(15), ScreenX375(150), ScreenX375(40))];
                nameLabel.textColor = FONTCOLOR_BLACK;
                nameLabel.font = Kfont(16);
                nameLabel.text =_pro.userName;
                [cell addSubview:nameLabel];
                
                UIView *line = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(70) +  - 1, SCREEN_WIDTH - ScreenX375(32), 1)];
                line.backgroundColor = REXADECIMALCOLOR(@"#f2f2f2");
                [cell addSubview:line];
                
                UIButton *concernBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(89), ScreenX375(25), ScreenX375(65), ScreenX375(30))];
                if ([_pro.isFollow integerValue]) {
                    [concernBtn setTitle:@"已关注" forState:UIControlStateNormal];
                    [concernBtn setTitleColor:REXADECIMALCOLOR(@"#212121") forState:UIControlStateNormal];
                    [concernBtn setImage:nil forState:UIControlStateNormal];
                }else {
                    [concernBtn setTitle:@" 关注" forState:UIControlStateNormal];
                    [concernBtn setTitleColor:REXADECIMALCOLOR(@"#ff2469") forState:UIControlStateNormal];
                    [concernBtn setImage:ImageWithName(@"添加关注") forState:UIControlStateNormal];
                }
                concernBtn.layer.borderWidth = 1;
                concernBtn.layer.borderColor = REXADECIMALCOLOR(@"#eaeaea").CGColor;
                concernBtn.clipsToBounds = YES;
                concernBtn.titleLabel.font = Kfont(14);
                concernBtn.layer.cornerRadius = ScreenX375(15);
                [concernBtn addTarget:self action:@selector(concern:) forControlEvents:UIControlEventTouchUpInside];
                [cell addSubview:concernBtn];
            }
            return cell;
        }else {
            static NSString *cellId = @"circleCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                self.cycleBannerViewBottom = [KDCycleBannerView new];
                self.cycleBannerViewBottom.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(355) + STATUS_BAR_HEIGHT); //位置及宽高
                self.cycleBannerViewBottom.datasource = self;
                self.cycleBannerViewBottom.delegate = self;
                self.cycleBannerViewBottom.continuous = YES; //是否连续显示
                self.cycleBannerViewBottom.autoPlayTimeInterval = 4; //时间间隔
                self.cycleBannerViewBottom.clipsToBounds = YES;
                [cell addSubview:self.cycleBannerViewBottom];
                
                self.videoBtn = [[UIButton alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - ScreenX375(50)) / 2, ScreenX375(150) + STATUS_BAR_HEIGHT, ScreenX375(50), ScreenX375(50))];
                [self.videoBtn setImage:ImageWithName(@"Group 9") forState:UIControlStateNormal];
                [self.videoBtn addTarget:self action:@selector(playVideo) forControlEvents:UIControlEventTouchUpInside];
                self.videoBtn.hidden = YES;
                [cell addSubview:self.videoBtn];
            }
            if (_pro) {
                if (_pro.videoUrl.length > 0) {
                    self.videoBtn.hidden = NO;
                }
            }
            return cell;
        }
    }else if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            static NSString *cellId = @"textCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            for (UIView *view in cell.subviews) {
                [view removeFromSuperview];
            }
            if (_pro) {
                UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(18), SCREEN_WIDTH - ScreenX375(32), ScreenX375(24))];
                titleLabel.text = _pro.proName;
                titleLabel.textColor = REXADECIMALCOLOR(@"#333333");
                titleLabel.font = KBlodfont(18);
                [cell addSubview:titleLabel];
                
                UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(58), SCREEN_WIDTH - ScreenX375(32), ScreenX375(20))];
                noteLabel.text = @"设计理念";
                noteLabel.textColor = REXADECIMALCOLOR(@"#333333");
                noteLabel.font = KBlodfont(16);
                [cell addSubview:noteLabel];
                
                CGFloat height = kGetStringHeight(_pro.designIdea, CGSizeMake(SCREEN_WIDTH - ScreenX375(32), MAXFLOAT), Kfont(15)) + ScreenX375(4);
                UILabel *contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(84), SCREEN_WIDTH - ScreenX375(32), height)];
                contentLabel.text = _pro.designIdea;
                contentLabel.textColor = REXADECIMALCOLOR(@"#666666");
                contentLabel.font = Kfont(15);
                contentLabel.numberOfLines = 0;
                [cell addSubview:contentLabel];
            }
            return cell;
        }else {
            static NSString *cellId = @"imageCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            for (UIView *view in cell.subviews) {
                [view removeFromSuperview];
            }
            return cell;
        }
    }else if (indexPath.section == 2 + _ideaArray.count) {
        if (indexPath.row == 0) {
            static NSString *cellId = @"proDetailCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            for (UIView *view in cell.subviews) {
                [view removeFromSuperview];
            }
            NSArray *noteArr = @[@"性别:",@"季节:",@"场景:",@"配饰:",@"款式:",@"年龄:",@"尺码:",@"频道:"];
            NSArray *detailArr = @[@"性别:",@"季节:",@"场景:",@"配饰:",@"款式:",@"年龄:",@"尺码:",@"频道:"];
            if (_pro) {
                NSString *sex = @"";
                if (_pro.sex) {
                    sex = _pro.sex;
                }
                NSString *type = @"";
                if (_pro.type) {
                    type = _pro.type;
                }
                NSString *season = @"";
                if (_pro.season) {
                    season = _pro.season;
                }
                NSString *channelName = @"";
                if (_pro.channelName) {
                    channelName = _pro.channelName;
                }
                if ([_pro.status integerValue]) {
                    NSString *ornament = @"";
                    if (_pro.ornament) {
                        ornament = _pro.ornament;
                    }
                    NSString *ages = @"";
                    if (_pro.ages) {
                        ages = _pro.ages;
                    }
                    NSString *size = @"";
                    if (_pro.size) {
                        size = _pro.size;
                    }
                    detailArr = @[sex,season,@"",ornament,type,ages,size,channelName];
                    UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(20) + 5 * ScreenX375(36), ScreenX375(80), ScreenX375(16))];
                    noteLabel.text = @"作品展示:";
                    noteLabel.textColor = REXADECIMALCOLOR(@"#333333");
                    noteLabel.font = KBlodfont(16);
                    [cell addSubview:noteLabel];
                }else {
                    noteArr = @[@"性别:",@"款型:",@"季节:",@"频道:"];
                    detailArr = @[sex,type,season,channelName];
                }
            }
            for (int i = 0; i < noteArr.count; i++) {
                UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16) + i / 5 * ScreenX375(168), ScreenX375(20) + i % 5 * ScreenX375(36), ScreenX375(48), ScreenX375(16))];
                noteLabel.text = noteArr[i];
                noteLabel.textColor = REXADECIMALCOLOR(@"#333333");
                noteLabel.font = KBlodfont(16);
                [cell addSubview:noteLabel];
                
                UILabel *detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(65) + i / 5 * ScreenX375(168), ScreenX375(20) + i % 5 * ScreenX375(36), ScreenX375(110), ScreenX375(16))];
                detailLabel.text = detailArr[i];
                detailLabel.textColor = REXADECIMALCOLOR(@"#666666");
                detailLabel.font = Kfont(16);
                [cell addSubview:detailLabel];
                
                if (noteArr.count == 4) {
                    noteLabel.frame = CGRectMake(ScreenX375(16) + i / 2 * ScreenX375(168), ScreenX375(20) + i % 2 * ScreenX375(36), ScreenX375(48), ScreenX375(16));
                    detailLabel.frame = CGRectMake(ScreenX375(65) + i / 2 * ScreenX375(168), ScreenX375(20) + i % 2 * ScreenX375(36), ScreenX375(110), ScreenX375(16));
                }
            }
            
            return cell;
        }else {
            static NSString *cellId = @"proShowCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            for (UIView *view in cell.subviews) {
                [view removeFromSuperview];
            }
            if (_pro) {
                UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(16), 0, SCREEN_WIDTH - ScreenX375(32), ScreenX375(343))];
                [imageView sd_setImageWithURL:[NSURL URLWithString:_pro.garmentPic] placeholderImage:nil options:SDWebImageRetryFailed];
                imageView.layer.cornerRadius = ScreenX375(6);
                imageView.clipsToBounds = YES;
                imageView.contentMode = UIViewContentModeScaleAspectFill;
                [cell addSubview:imageView];
            }
            return cell;
        }
    }else if (indexPath.section == 3 + _ideaArray.count) {
        if (indexPath.row == 0) {
            CommentTableViewCell *cell = [CommentTableViewCell cellWithTableView:tableView andIndexPath:indexPath];
            cell.commentModel = _commentArr[indexPath.row];
            CommentModel *model = _commentArr[indexPath.row];
            cell.appraiseClick = ^{
                [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/zan",REQUESTHEADER] andParameter:@{@"proId":model.Id,@"userId":kNSUDefaultReadKey(@"userId"),@"type":@"1"} success:^(id successResponse) {
                    NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
                    if ([status isEqualToString:@"200"]) {
                        if ([model.isZan integerValue]) {
                            model.isZan = @"0";
                            model.zanNum = [NSString stringWithFormat:@"%ld",[model.zanNum integerValue] - 1];
                        }else {
                            model.isZan = @"1";
                            model.zanNum = [NSString stringWithFormat:@"%ld",[model.zanNum integerValue] + 1];
                        }
                        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
                    }else {
                        [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
                    }
                } andFailure:^(id failureResponse) {
                    [HttpManager showFail];
                }];
            };
            cell.commentClick = ^{
                self.appraiseId = model.Id;
                [self commentClick];
            };
            return cell;
        }else {
            static NSString *cellId = @"moreCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                UIImage *bgImg = [UIImage gradientColorImageFromColors:@[REXADECIMALCOLOR(@"#ff1061"),REXADECIMALCOLOR(@"#fd4c4e")] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(ScreenX375(100), ScreenX375(34))];
                UIButton *buyBtn = [[UIButton alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - ScreenX375(100)) / 2, ScreenX375(11), ScreenX375(100), ScreenX375(34))];
                [buyBtn setTitle:@"查看全部" forState:UIControlStateNormal];
                buyBtn.titleLabel.font = Kfont(14);
                [buyBtn setTitleColor:REXADECIMALCOLOR(@"#ffffff") forState:UIControlStateNormal];
                buyBtn.layer.cornerRadius = ScreenX375(17);
                buyBtn.clipsToBounds = YES;
                [buyBtn setBackgroundImage:bgImg forState:UIControlStateNormal];
                [buyBtn addTarget:self action:@selector(showAll:) forControlEvents:UIControlEventTouchUpInside];
                [cell addSubview:buyBtn];
            }
            return cell;
        }
    }else if (indexPath.section == 4 + _ideaArray.count) {
        if (indexPath.row == 0) {
            static NSString *cellId = @"likeCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            for (UIView *subView in cell.subviews) {
                [subView removeFromSuperview];
            }
            UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16), 0, ScreenX375(150), ScreenX375(56))];
            noteLabel.text = @"相似设计";
            noteLabel.textColor = REXADECIMALCOLOR(@"#212121");
            noteLabel.font = KBlodfont(24);
            [cell addSubview:noteLabel];
            
            UILabel *numLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(116), 0, ScreenX375(100), ScreenX375(56))];
            numLabel.text = [NSString stringWithFormat:@"%lu个作品",(unsigned long)self.similarArray.count];
            numLabel.textColor = REXADECIMALCOLOR(@"#ababab");
            numLabel.font = Kfont(14);
            numLabel.textAlignment = NSTextAlignmentRight;
            [cell addSubview:numLabel];
            
            if (self.similarArray.count > 0) {
                UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, ScreenX375(56), SCREEN_WIDTH, ScreenX375(190))];
                scrollView.showsVerticalScrollIndicator = false;
                scrollView.showsHorizontalScrollIndicator = false;
                scrollView.delegate = self;
                scrollView.contentSize = CGSizeMake(ScreenX375(16) + self.similarArray.count * ScreenX375(204), 0);
                [cell addSubview:scrollView];
                
                for (int i = 0; i < self.similarArray.count; i++) {
                    MoreDesignView *view = [[MoreDesignView alloc] initWithFrame:CGRectMake(i * ScreenX375(204) + ScreenX375(16), 0, ScreenX375(188), ScreenX375(190))];
                    view.designModel = self.similarArray[i];
                    DesignModel *model = self.similarArray[i];
                    view.detailClick = ^{
                        MoreDetailViewController *vc = [[MoreDetailViewController alloc] init];
                        vc.proId = model.Id;
                        [self.navigationController pushViewController:vc animated:YES];
                    };
                    view.concernClick = ^{
                        [HttpManager postHttpRequestByPost:[NSString stringWithFormat:@"%@api/concern",REQUESTHEADER] andParameter:@{@"concernId":kNSUDefaultReadKey(@"userId"),@"concernedId":model.userId} success:^(id successResponse) {
                            NSString *status = [NSString stringWithFormat:@"%@",successResponse[@"code"]];
                            if ([status isEqualToString:@"200"]) {
                                if ([model.isZan integerValue]) {
                                    model.isZan = @"0";
                                    [HttpManager showNoteMsg:@"取消关注成功"];
                                }else {
                                    model.isZan = @"1";
                                    [HttpManager showNoteMsg:@"关注成功"];
                                }
                                [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
                            }else {
                                [HttpManager showNoteMsg:[NSString stringWithFormat:@"%@",successResponse[@"msg"]]];
                            }
                        } andFailure:^(id failureResponse) {
                            [HttpManager showFail];
                        }];
                    };
                    [scrollView addSubview:view];
                }
            }
            return cell;
        }else {
            static NSString *cellId = @"operateCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.backgroundColor = TABLEVIEW_BACKGROUNDCOLOR;
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            return cell;
        }
    }else {
        if (indexPath.row == 0) {
            static NSString *cellId = @"newTextCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            for (UIView *view in cell.subviews) {
                [view removeFromSuperview];
            }
            if (_pro) {
                UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(18), SCREEN_WIDTH - ScreenX375(32), ScreenX375(20))];
                noteLabel.text = @"新增设计理念";
                noteLabel.textColor = REXADECIMALCOLOR(@"#333333");
                noteLabel.font = KBlodfont(16);
                [cell addSubview:noteLabel];
                
                CGFloat height = kGetStringHeight(_pro.proIdeas[indexPath.section - 2][@"idea"], CGSizeMake(SCREEN_WIDTH - ScreenX375(32), MAXFLOAT), Kfont(15)) + ScreenX375(4);
                UILabel *contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(46), SCREEN_WIDTH - ScreenX375(32), height)];
                contentLabel.text = _pro.proIdeas[indexPath.section - 2][@"idea"];
                contentLabel.textColor = REXADECIMALCOLOR(@"#666666");
                contentLabel.font = Kfont(15);
                contentLabel.numberOfLines = 0;
                [cell addSubview:contentLabel];
            }
            return cell;
        }else {
            static NSString *cellId = @"newImageCell";
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (cell == nil) {
                cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            for (UIView *view in cell.subviews) {
                [view removeFromSuperview];
            }
            if (_pro) {
                UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(16), 0, SCREEN_WIDTH - ScreenX375(32), ScreenX375(186))];
                [imageView sd_setImageWithURL:[NSURL URLWithString:_pro.proIdeas[indexPath.section - 2][@"pic"]] placeholderImage:nil options:SDWebImageRetryFailed];
                imageView.layer.cornerRadius = ScreenX375(6);
                imageView.clipsToBounds = YES;
                imageView.contentMode = UIViewContentModeScaleAspectFill;
                [cell addSubview:imageView];
            }
            return cell;
        }
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 3 + _ideaArray.count) {
        if (indexPath.row == 0) {
            CommentModel *model = self.commentArr[0];
            CGFloat height = kGetStringHeight(model.content, CGSizeMake(SCREEN_WIDTH - ScreenX375(64), MAXFLOAT), Kfont(14));
            if (model.list.count > 0) {
                NSDictionary *dic = model.list[0];
                NSError *error;
                CommentModel *replyModel = [[CommentModel alloc] initWithDictionary:dic error:&error];
                CGFloat height1 = kGetStringHeight(replyModel.content, CGSizeMake(SCREEN_WIDTH - ScreenX375(128), MAXFLOAT), Kfont(13)) + ScreenX375(62);
                height += height1;
            }
            
            return height + ScreenX375(66);
        }
        return ScreenX375(61);
    }else if (indexPath.section == 2 + _ideaArray.count) {
        if (indexPath.row == 1) {
            return ScreenX375(350);
        }
        if (_pro) {
            if ([_pro.status integerValue]) {
                return ScreenX375(226);
            }
        }
        return ScreenX375(92);
    }else if (indexPath.section == 4 + _ideaArray.count) {
        if (indexPath.row == 0) {
            if (self.similarArray.count == 0) {
                return ScreenX375(56);
            }
            return ScreenX375(246);
        }
        return 0;
    }else if (indexPath.section == 1) {
        if (indexPath.row == 1) {
            return ScreenX375(0);
        }
        CGFloat height = kGetStringHeight(_pro.designIdea, CGSizeMake(SCREEN_WIDTH - ScreenX375(32), MAXFLOAT), Kfont(15)) + ScreenX375(4);
        return ScreenX375(94) + height;
    }else if (indexPath.section == 0) {
        if (indexPath.row == 1) {
            return ScreenX375(70);
        }
        return ScreenX375(355) + STATUS_BAR_HEIGHT;
    }
    if (indexPath.row == 1) {
        return ScreenX375(186);
    }
    CGFloat height = kGetStringHeight(_pro.proIdeas[indexPath.section - 2][@"idea"], CGSizeMake(SCREEN_WIDTH - ScreenX375(32), MAXFLOAT), Kfont(15)) + ScreenX375(4);
    return ScreenX375(56) + height;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 3 + _ideaArray.count) {
        return ScreenX375(44);
    }
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if (section >= 2 + _ideaArray.count) {
        return ScreenX375(10);
    }
    return 0.01;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if (section == 3 + _ideaArray.count) {
        UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(44))];
        headView.backgroundColor = [UIColor whiteColor];
        
        UIView *redLine = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(15), ScreenX375(3), ScreenX375(14))];
        redLine.backgroundColor = REXADECIMALCOLOR(@"#ff235d");
        [headView addSubview:redLine];
        
        UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(25), 0, ScreenX375(100), ScreenX375(44))];
        noteLabel.text = @"评论";
        noteLabel.font = Kfont(15);
        noteLabel.textColor = REXADECIMALCOLOR(@"#333333");
        [headView addSubview:noteLabel];
        
        UILabel *commentNumLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(166), 0, ScreenX375(150), ScreenX375(44))];
        commentNumLabel.text = [NSString stringWithFormat:@"共%lu条评论 >",(unsigned long)self.commentArr.count];
        commentNumLabel.textColor = REXADECIMALCOLOR(@"#666666");
        commentNumLabel.font = Kfont(13);
        commentNumLabel.textAlignment = NSTextAlignmentRight;
        [headView addSubview:commentNumLabel];
        
        UIButton *allBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(160), 0, ScreenX375(150), ScreenX375(44))];
        [allBtn addTarget:self action:@selector(showAll:) forControlEvents:UIControlEventTouchUpInside];
        [headView addSubview:allBtn];
        
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(16), ScreenX375(44) - 0.5, SCREEN_WIDTH - ScreenX375(32), 0.5)];
        line.backgroundColor = REXADECIMALCOLOR(@"#e4e4e4");
        [headView addSubview:line];
        
        return headView;
    }
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    if (section >= 2 + _ideaArray.count) {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenX375(10))];
        view.backgroundColor = RGB_COLOR(244, 244, 244);
        return view;
    }
    return nil;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return NO;
}

#pragma mark 轮播图代理委托

- (NSArray *)numberOfKDCycleBannerView:(KDCycleBannerView *)bannerView{
    NSMutableArray *urlArray = [NSMutableArray array];
    if (_pro) {
        for (int i = 0; i < _pro.coverPics.count; i++) {
            NSString *url = [NSString stringWithFormat:@"%@",_pro.coverPics[i]];
            [urlArray addObject:url];
        }
    }
    return urlArray;
}

- (UIViewContentMode)contentModeForImageIndex:(NSUInteger)index{
    return UIViewContentModeScaleAspectFill;
}

- (void)cycleBannerView:(KDCycleBannerView *)bannerView didSelectedAtIndex:(NSUInteger)index{
    NSLog(@"点击了第%ld个",(long)index);
}

-(void)textViewDidBeginEditing:(UITextView *)textView{
    if (textView.tag == 555) {
        if ([textView.text isEqualToString:@"写评论..."]) {
            textView.textColor = [UIColor blackColor];
            textView.text = @"";
        }
    }
}

- (void)textViewDidEndEditing:(UITextView *)textView {
    if (textView.tag == 500) {
        if (textView.text.length < 1) {
            textView.textColor = REXADECIMALCOLOR(@"#999999");
            textView.text = @"写评论...";
        }
    }
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

@implementation ProductModel

+(JSONKeyMapper*)keyMapper
{
    return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
                                                                  @"Id": @"id"
                                                                  }];
}


@end

